#include<client.hpp>
#include<server.hpp>
#include <iostream>

#include "globalVar.h"
#include "XApplication.hpp"

//创建服务器
void test_createTcpServer(TcpServer **server){
	*server = new TcpServer("127.0.0.1",9936);
}

//关闭服务器
void test_stopTcpServer(TcpServer **p){
	if(*p!= nullptr)
		delete *p;
	*p = nullptr;
}

//创建客户端
void test_createTcpClient(TcpClient **client){
	*client = new TcpClient("127.0.0.1",9936);
}

int main(int argc,char**argv)
{
	TcpServer *server = nullptr;
	TcpClient *client = nullptr;

	XApplication<int> a(argc,argv);
	a.registerCallback(1,test_createTcpServer, &server);
	a.registerCallback(2,test_createTcpClient, &client);
	a.registerCallback(3,test_stopTcpServer,    &server);
	a.m_content =  "//---------------------------------------\n"
                    "功能列表\n"
                    "1    createTcpServer\n"
                    "2    createTcpClient\n"
                    "3    stopTcpServer\n"
				   "//---------------------------------------\n";
    return a.exec([](std::string str)->int{return std::stoi(str);}); 
}